//
//  PickNumSportTableViewViewController.m
//  PlayBall
//
//  Created by Jdd‘s macbook on 13-10-25.
//
//

#import "JddPickNumSportTableView.h"

@interface JddPickNumSportTableView ()

@end

@implementation JddPickNumSportTableView

-(void)viewDidLoad{
    [super viewDidLoad];
    self.sportlotterylist = [[JddSportNumberList alloc] init];
    
}

-(void)refreshTableView
{
    NSArray *tableData = [self.sResult objectFromJSONString];
    CGRect frame = SPORT_CHILD_VIEW_FRAME;
    //让球胜平负，胜平负，总进球
    if (self.lottId == LOTTERY_PLAY_METHOD_FOOTBALL || self.lottId == LOTTERY_PLAY_METHOD_FOOTBALL_SPF || self.lottId == LOTTERY_PLAY_METHOD_FOOTBALL_ZJQ) {
        [tableView_RQ_SPF_ZJQ removeFromParentViewController];
        [tableView_RQ_SPF_ZJQ.view removeFromSuperview];
        tableView_RQ_SPF_ZJQ = [[JddRQ_SPF_ZJQ_TableView alloc] init];
        tableView_RQ_SPF_ZJQ.tableData = tableData;
        tableView_RQ_SPF_ZJQ.delegate = self;
        tableView_RQ_SPF_ZJQ.lottId = self.lottId;
        tableView_RQ_SPF_ZJQ.sportlotterylist = self.sportlotterylist;

        [self addChildViewController:tableView_RQ_SPF_ZJQ];
        tableView_RQ_SPF_ZJQ.view.frame = frame;
        [self.view addSubview:tableView_RQ_SPF_ZJQ.view];
    }
    //比分过关 /半全场过关
    else if (self.lottId == LOTTERY_PLAY_METHOD_FOOTBALL_BF || self.lottId == LOTTERY_PLAY_METHOD_FOOTBALL_BQC){
        [bf_tableView removeFromParentViewController];
        [bf_tableView.view removeFromSuperview];
        bf_tableView = [[JddBF_TableView alloc] init];
        bf_tableView.tableData = tableData;
        bf_tableView.delegate = self;
        bf_tableView.lottId = self.lottId;
        bf_tableView.sportlotterylist = self.sportlotterylist;
        [self addChildViewController:bf_tableView];
        bf_tableView.view .frame = frame;
        [self.view addSubview:bf_tableView.view];
    }
    //混合过关
    else if (self.lottId == LOTTERY_PLAY_METHOD_FOOTBALL_HH){
        [hh_tableView removeFromParentViewController];
        [hh_tableView.view removeFromSuperview];
        hh_tableView = [[JddHH_TableView alloc] init];
        hh_tableView.tableData = tableData;
        hh_tableView.delegate = self;
        hh_tableView.sportlotterylist = self.sportlotterylist;
        [self addChildViewController:hh_tableView];
        hh_tableView.view .frame = frame;
        [self.view addSubview:hh_tableView.view];
    }
}

-(void)selectMatch
{
    NSString *label3Text = @"----";
    if ([self.sportlotterylist.sportList count]>0) {
        JddSportNumber *sportnum1 = [self.sportlotterylist.sportList objectAtIndex:0];
        NSDate *date1 = [JddCommonFunction dateFromString:sportnum1.endTime];
        for (JddSportNumber *sportnum in self.sportlotterylist.sportList) {
            NSDate *date2 = [JddCommonFunction dateFromString:sportnum.endTime];
            date1 = [date2 earlierDate:date1];
        }
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
        label3Text = [dateFormatter stringFromDate:date1];
    }
    NSString *label2Text = [NSString stringWithFormat:@"共选择%d场比赛,截止时间：",[self.sportlotterylist.sportList count]];
    
    [self.delegate performSelector:@selector(selectMatch::) withObject:label2Text withObject:label3Text];
}


@end
